<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Configures whether to keep the loop from returning</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="evwatcher.invoke.html">EvWatcher::invoke</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="evwatcher.setcallback.html">EvWatcher::setCallback</a></div>
 <div class="up"><a href="class.evwatcher.html">EvWatcher</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="evwatcher.keepalive" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">EvWatcher::keepalive</h1>
  <p class="verinfo">(PECL ev &gt;= 0.2.0)</p><p class="refpurpose"><span class="refname">EvWatcher::keepalive</span> &mdash; <span class="dc-title">Configures whether to keep the loop from returning</span></p>

 </div>
 <div class="refsect1 description" id="refsect1-evwatcher.keepalive-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span>
   <span class="type">bool</span> 
   <span class="methodname"><strong>EvWatcher::keepalive</strong></span>
    ([ <span class="methodparam">
    <span class="type">bool</span>
     <code class="parameter">$value</code>
   </span>
  ] )</div>

  <p class="para rdfs-comment">
   Configures whether to keep the loop from returning. With keepalive
   <em><code class="parameter">value</code></em>
   set to <strong><code>FALSE</code></strong> the watcher won&#039;t keep
   <span class="methodname"><a href="ev.run.html" class="methodname">Ev::run()</a></span>
   /
   <span class="methodname"><a href="evloop.run.html" class="methodname">EvLoop::run()</a></span>
   from returning even though the watcher is active.
  </p>
  <p class="para">
   Watchers have keepalive
   <em><code class="parameter">value</code></em>
   <strong><code>TRUE</code></strong> by default.
  </p>
  <p class="para">
   Clearing keepalive status is useful when returning from
   <span class="methodname"><a href="ev.run.html" class="methodname">Ev::run()</a></span>
   /
   <span class="methodname"><a href="evloop.run.html" class="methodname">EvLoop::run()</a></span>
   just because of the watcher is undesirable. It could be a long running UDP
   socket watcher or so.
  </p>
 </div>

 <div class="refsect1 parameters" id="refsect1-evwatcher.keepalive-parameters">
  <h3 class="title">参数</h3>
  <dl>

   
    <dt>

     <em><code class="parameter">value</code></em>
    </dt>

    <dd>

     <p class="para">
      With keepalive
      <em><code class="parameter">value</code></em>
      set to <strong><code>FALSE</code></strong> the watcher won&#039;t keep
      <span class="methodname"><a href="ev.run.html" class="methodname">Ev::run()</a></span>
      /
      <span class="methodname"><a href="evloop.run.html" class="methodname">EvLoop::run()</a></span>
      from returning even though the watcher is active.
     </p>
    </dd>

   
  </dl>

 </div>

 <div class="refsect1 returnvalues" id="refsect1-evwatcher.keepalive-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   Returns the previous state.
  </p>
 </div>

 <div class="refsect1 examples" id="refsect1-evwatcher.keepalive-examples">
  <h3 class="title">范例</h3>
  <div class="example" id="example-3542">
   <p><strong>Example #1 Register an I/O watcher for some UDP socket but do not keep the
   event loop from running just because of that watcher.</strong></p>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$udp_socket&nbsp;</span><span style="color: #007700">=&nbsp;...<br /></span><span style="color: #0000BB">$udp_watcher&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">EvIo</span><span style="color: #007700">(</span><span style="color: #0000BB">$udp_socket</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">Ev</span><span style="color: #007700">::</span><span style="color: #0000BB">READ</span><span style="color: #007700">,&nbsp;function&nbsp;()&nbsp;{&nbsp;</span><span style="color: #FF8000">/*&nbsp;...&nbsp;*/&nbsp;</span><span style="color: #007700">});<br /></span><span style="color: #0000BB">$udp_watcher</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">keepalive</span><span style="color: #007700">(</span><span style="color: #0000BB">FALSE</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
   </div>

  </div>
 </div>

</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="evwatcher.invoke.html">EvWatcher::invoke</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="evwatcher.setcallback.html">EvWatcher::setCallback</a></div>
 <div class="up"><a href="class.evwatcher.html">EvWatcher</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
